<?php
/**
 * 编辑器上传
 * @author kim007
 *
 */
class AttachAction extends Action{

	public function _initialize() {
		exit;
		$passport	=	service('Passport');

		//验证登陆
		if(!$passport->isLogged()){
			echo "-1";	//没有权限，需要登陆后上传
		}
	}


	//kissy编辑器上传
	public function kissy(){

		//执行附件上传操作
		$attach_type	=	'kissy';

		$options['uid']			=	$this->mid;
		$options['allow_exts']	=	'jpg,jpeg,bmp,png,gif';
		$info	=	X('Xattach')->upload($attach_type,$options);
		
		if(is_array($info['info'])){
			//$image_url	=	SITE_URL.'/data/uploads/'.$info['info'][0]['savepath'].$info['info'][0]['savename'];
			$image_url	=	'/data/uploads/'.$info['info'][0]['savepath'].$info['info'][0]['savename'];
		}

		//上传成功
		if($info['status']==true){
			echo '{"status": "0", "imgUrl": "' .$image_url. '"}';
		}else{
			echo '{"status": "1", "error": "'.$info['info'].'"}';
		}
	}

}
?>